#include "stdafx.h"
#include <boost/test/auto_unit_test.hpp>
#include "bmock.hpp"

static void f(int* x, char* y, char* z) {
	STATIC_MOCK_VOID(3,(IN_OUT(x),RAW_MEM(IN_OUT,y,1),IN_OUT(z)));
}

static const char *z_in_  = "A";
static const char *z_out_ = "B";
static const int  x_in_   = 11;
static const int  x_out_  = 211;
static const char y_in_   = 'A';
static const char y_out_  = 'B';

struct ignore_tester {
	ignore_tester()
		:x_(x_in_)
		,y_(y_in_)
	{
		strcpy(z_,z_in_);
	}
	~ignore_tester() {
		BMOCK_VERIFY;
	}

	int  x_;
	char y_;
	char z_[2];
};

BMOCK_TEST(ignore_tester,test_ignore_IN) {
	BMOCK_EXPECT(f(bmock::out_raw_mem(x_out_),bmock::out_raw_mem(&y_out_,1),bmock::out_str(z_out_)));
	BMOCK_REPLAY;
	f(&x_,&y_,z_);
	BOOST_CHECK_EQUAL(x_,x_out_);
	BOOST_CHECK_EQUAL(y_,y_out_);
	BOOST_CHECK_EQUAL(z_,z_out_);
}

BMOCK_TEST(ignore_tester,test_ignore_OUT) {
	BMOCK_EXPECT(f(bmock::in_raw_mem(x_in_),bmock::in_raw_mem(&y_in_,1),bmock::in_str(z_in_)));
	BMOCK_REPLAY;
	f(&x_,&y_,z_);
	BOOST_CHECK_EQUAL(x_,x_in_);
	BOOST_CHECK_EQUAL(y_,y_in_);
	BOOST_CHECK_EQUAL(z_,z_in_);
}

BMOCK_TEST(ignore_tester,test_ignore_IN_OUT) {
	int x1 = 88;
	char y1 = 'W';
	char z1[2] = "Z";

	BMOCK_EXPECT(f(bmock::in_out_raw_mem<int>(),bmock::in_out_raw_mem<char>(),bmock::in_out_str()));
	BMOCK_REPLAY;
	f(&x1,&y1,z1);
	BOOST_CHECK_EQUAL(x1,x1);
	BOOST_CHECK_EQUAL(y1,y1);
	BOOST_CHECK_EQUAL(z1,z1);
}

